
import { constantRoutes, asyncRoutes } from '@/router'
console.log(constantRoutes, asyncRoutes, 666666)

export default {
  namespaced: true,
  state: {
    //  显示sideBar
    routes: [],
    points: []
  },
  mutations: {
    SET_ROUTES: (state, { newRoutes, points }) => {
      state.routes = [...constantRoutes, ...newRoutes]
      state.points = points
    }
  },
  actions: {
    //  处理数据的函数
    froute ({ commit }, { menus, points }) {
      /* 筛选当前用户的权限点  仓库中的获取了然后从所有的权限中去筛选 */
      var newRoutes = []
      menus.forEach(key => {
        newRoutes.push(...asyncRoutes.filter(item => item.name === key))
      })
      console.log(newRoutes, 123)

      commit('SET_ROUTES', { newRoutes, points })
      return newRoutes
    }
  }
}
